﻿#ifndef LIBNCACORE_GLOBAL_H
#define LIBNCACORE_GLOBAL_H

#include <QtCore/qglobal.h>
#include <math.h>

#if defined(NCA_LIBRARY)
#  define NCA_EXPORT Q_DECL_EXPORT
#else
#  define NCA_EXPORT Q_DECL_IMPORT
#endif

// This WILL cause problems
// http://stackoverflow.com/questions/14297515/calculating-greatest-common-divisor
// but for now I don't know any alternatives :)
double inline gcd(double a, double b)
  {
  if (a < 0)
    a = -a;
  if (b < 0)
    b = -b;

  if (a > b)
    {
    if(b == 0)
      return a;
    else
      return gcd(b, fmod(a,b));
    }
  else
    {
    if (a == 0)
      return b;
    else
      return gcd(fmod(b,a), a);
    }
  }

#endif // LIBNCACORE_GLOBAL_H
